#include "client.h"

int pathSepa(char* pathName, char* srcName, char* destName) {
    //将源路径和目标路径分开
    int lengthOfPath = strlen(pathName);
    int j;
    for(j = 0; j < lengthOfPath; j++) {
        if(pathName[j] == ' ') {
            break;
        }
    }
    memcpy(srcName, pathName, j);
    while(pathName[j] == ' ') {
        j++;
    }
    strcpy(destName, pathName + j);

    //去掉前置和后置的/
    int lengthOfSrc = strlen(srcName);
    int lengthOfDest = strlen(destName);
    if(srcName[lengthOfSrc - 1] == '/') {
        srcName[lengthOfSrc - 1] = 0;
        lengthOfSrc--;
    }
    if(srcName[0] == '/') {
        memmove(srcName, srcName + 1, lengthOfSrc - 1);
        lengthOfSrc--;
    }
    if(destName[lengthOfDest - 1] == '/') {
        destName[lengthOfDest - 1] = 0;
        lengthOfDest--;
    }
    if(destName[0] == '/') {
        memmove(destName, destName + 1, lengthOfDest - 1);
        lengthOfDest--;
    }
    return 0;
}
